package ru.spb.nicetu.altx.mnemo.math.managers;

import java.util.HashMap;
import java.util.Map;

import ru.spb.nicetu.altx.mnemo.node.INode;

public class NodeManager {
  protected NodeManager() {
  }

  private static NodeManager instance = new NodeManager();

  public static NodeManager getInstance() {
    return instance;
  }

  private Map<Long, INode> nodes = new HashMap<Long, INode>();

  public void addNode(INode node) {
    nodes.put(node.getID(), node);
  }

  public INode[] getAllNodes() {
    return nodes.values().toArray(new INode[0]);
  }

  public INode getNodeByID(long id) {
    return nodes.get(id);
  }
  
  public void removeNode(INode node){
	  if (node != null);
	  nodes.remove(node.getID());
  }
  
  public void removeNode(long id) {
	  nodes.remove(id);
  }

}
